package com.shang.sync.demo;


public class Test {
    public static void main(String args[]){
        Cabinet cabinet = new Cabinet();
        for (int i = 0; i < 3; i++) {
            final int number = i;
            new Thread(() -> {
                User user = new User(cabinet,number);
                synchronized (cabinet){
                    user.userCabinet();
                    System.out.println("我是用户: " + number + ",我存储的数字是: " + cabinet.getNumber());
                }
            },String.valueOf(i)).start();
        }
    }
}
